var { clickUtils, gUtils } = require("../shizukuUtils/index");
var utils = require("./utils");
var pointMap = {
  首页: {
    推荐: [[137, 220, 306, 336], 1080, 2340],
    关注: [[0, 220, 137, 336], 1080, 2340],
    精选: [[306, 220, 443, 336], 1080, 2340],
    首页: [[47, 2176, 168, 2253], 1080, 2340],
    放映厅: [[216, 2165, 432, 2296], 1080, 2340],
    商城: [[648, 2165, 864, 2296], 1080, 2340],
    我的: [[911, 2176, 1032, 2253], 1080, 2340],
  },
};

function refresh() {
  clickUtils.clickPointMap(pointMap.首页.我的);
  gUtils.sleep(3, 6);
  clickUtils.clickPointMap(pointMap.首页.首页);
}
function read() {
  var aaa = gUtils.sleep(1 * 30, 1.5 * 60);
  if (gUtils.possible(1, 15)) {
    utils.goHome();
    gUtils.sleep(5, 10);
    app.launchApp("西瓜视频");
  }
  var bbb = gUtils.sleep(1 * 30, 1.5 * 60);
  return aaa + bbb;
}

Wang.main = function (max) {
  var max = Number(max || 180);
  var hasRead = 0;
  while (gUtils.getMin(hasRead) < max) {
    refresh();
    var readDuration = read();
    hasRead += readDuration;
  }
};
